# Top level Seapilot Make

include macros.gmk

TARGETS := 
# all targets: dynconsumer dynsql mal publications xmlgateway event_templates text_protocol_adapter 

.PHONY: all
all:  dbsecurity-dependent sql-dependent standalone scripts

.PHONY: sql-dependent
sql-dependent: dynconsumer dynsql universal_consumer lighthouse2 \
	text_protocol_adapter problem_management problem_management_dll \
	timer_pop_generator node_status_agent chameleon uaa snmppa una se_metrics_aaa_delta \
	linux_counter_coremetrics linux_counter_networkmetrics linux_counter_loadavg linux_counter_diskmetrics \
	linux_counter_virtualmemmetrics linux_counter_filesystem linux_counter_memorymetrics \
	lx_loadavg_metrics lx_diskinfo_metrics lx_physnode_metrics

.PHONY: standalone
standalone: publications wrapper wrapper_sq wrapper_mon consumer_wrapper \
	mal xmlgateway sqqpidcommon event_tokenizer event_templates event_send \
	protobuf_serialization protobuf_serialization_sq \
	problem_management_common problem_management_spjs \
	test_consumer_producer unc_configuration_generator querystatsload \
	tpaload scripts

.PHONY: dbsecurity-dependent
dbsecurity-dependent: dbsevents dbaudit

.PHONY: dbsevents
dbsevents: publications
	cd ../../dbsecurity/shared/dbsevents; $(MAKE)
	
.PHONY: dbaudit
dbaudit: dbsevents
	cd ../../dbsecurity/shared/dbaudit; $(MAKE)

.PHONY: wrapper
wrapper: publications
	cd source/wrapper; $(MAKE)

.PHONY: wrapper_sq
wrapper_sq: publications
	cd source/wrapper_sq; $(MAKE)

.PHONY: wrapper_mon
wrapper_mon: publications
	cd source/wrapper_mon; $(MAKE)

.PHONY: consumer_wrapper
consumer_wrapper: publications
	cd source/consumer_wrapper; $(MAKE)

.PHONY: una
una: wrapper chameleon
	cd source/una; $(MAKE)

.PHONY: mal
mal:
	cd source/mal; $(MAKE)

.PHONY: publications
publications:
	cd source/publications; $(MAKE)

.PHONY: unc_configuration_generator
unc_configuration_generator:
	cd source/unc_configuration_generator; $(MAKE)

.PHONY: node_status_agent
node_status_agent: wrapper_sq
	cd source/node_status_agent; $(MAKE)

.PHONY: xmlgateway 
xmlgateway: publications wrapper
	cd source/xmlgateway; $(MAKE)

.PHONY: text_protocol_adapter
text_protocol_adapter: chameleon
	cd source/text_protocol_adapter; $(MAKE)

.PHONY: universal_consumer
universal_consumer: publications protobuf_serialization protobuf_serialization_sq wrapper_sq
	cd source/universal_consumer; $(MAKE)

.PHONY: snmppa
snmppa: publications consumer_wrapper chameleon
	cd source/snmppa; $(MAKE)

.PHONY: dynsql
dynsql:
	cd source/dynsql; $(MAKE)

.PHONY: dynconsumer
dynconsumer: dynsql wrapper_sq
	cd source/dynconsumer; $(MAKE)

.PHONY: lighthouse2
lighthouse2: publications wrapper
	cd source/lighthouse2; $(MAKE)

.PHONY: event_tokenizer 
event_tokenizer: publications wrapper
	cd source/event_tokenizer; $(MAKE)

.PHONY: event_send
event_send: publications wrapper
	cd source/event_send; $(MAKE)

.PHONY: event_templates
event_templates: source/event_templates/sql.error_event.template
	cd source/event_templates; $(MAKE)
source/event_templates/sql.error_event.template: ../../sql/bin/SqlciErrors.txt
	awk '/^[[:digit:]]/ {printf "109%06d SQL Error Message : $$~message_text\\nSQL Query id : $$~sqlid\n", $$1}' ../../sql/bin/SqlciErrors.txt > source/event_templates/sql.error_event.template	

.PHONY: protobuf_serialization
protobuf_serialization: wrapper mal
	cd source/protobuf_serialization; $(MAKE)

.PHONY: protobuf_serialization_sq
protobuf_serialization_sq: wrapper_sq mal
	cd source/protobuf_serialization_sq; $(MAKE)
	
.PHONY: test_consumer_producer
test_consumer_producer: protobuf_serialization consumer_wrapper
	cd source/test_consumer_producer; $(MAKE)

.PHONY: problem_management_dll
problem_management_dll: wrapper_sq publications problem_management_common
	cd source/problem_management_dll; $(MAKE)

.PHONY: problem_management
problem_management: wrapper_sq problem_management_common
	cd source/problem_management; $(MAKE)

.PHONY: problem_management_common
problem_management_common: publications mal
	cd source/problem_management_common; $(MAKE)

.PHONY: problem_management_spjs
problem_management_spjs:
	cd source/problem_management_spjs; $(MAKE)

.PHONY: timer_pop_generator
timer_pop_generator: wrapper_sq mal
	cd source/timer_pop_generator; $(MAKE)
	
.PHONY: chameleon 
chameleon: wrapper_sq publications
	cd source/chameleon; $(MAKE)

.PHONY: querystatsload
querystatsload: wrapper
	cd source/querystatsload; $(MAKE)

.PHONY: tpaload
tpaload: wrapper
	cd source/tpaload; $(MAKE)

.PHONY: uaa
uaa: chameleon 
	cd source/uaa; $(MAKE)

.PHONY: se_metrics_aaa_delta
se_metrics_aaa_delta: chameleon problem_management_dll
	cd source/se_metrics_aaa_delta; $(MAKE)
	
.PHONY: linux_counter_loadavg
linux_counter_loadavg: chameleon problem_management_dll
	cd source/linuxcounters/loadavg_metrics_sh; $(MAKE)

.PHONY: linux_counter_coremetrics
linux_counter_coremetrics: chameleon problem_management_dll
	cd source/linuxcounters/core_metrics_sh; $(MAKE)

.PHONY: linux_counter_networkmetrics
linux_counter_networkmetrics: chameleon problem_management_dll
	cd source/linuxcounters/network_metrics_sh; $(MAKE)

.PHONY: linux_counter_diskmetrics
linux_counter_diskmetrics: chameleon problem_management_dll
	cd source/linuxcounters/disk_metrics_sh; $(MAKE)

.PHONY: linux_counter_memorymetrics
linux_counter_memorymetrics: chameleon problem_management_dll
	cd source/linuxcounters/memory_metrics_sh; $(MAKE)	

.PHONY: linux_counter_filesystem
linux_counter_filesystem: chameleon problem_management_dll
	cd source/linuxcounters/filesystem_metrics_sh; $(MAKE)

.PHONY: linux_counter_virtualmemmetrics
linux_counter_virtualmemmetrics: chameleon problem_management_dll
	cd source/linuxcounters/virtualmem_metrics_sh; $(MAKE)

.PHONY: lx_loadavg_metrics
lx_loadavg_metrics: chameleon problem_management_dll
	cd source/linuxcounters/lx_loadavg_metrics; $(MAKE)

.PHONY: lx_diskinfo_metrics
lx_diskinfo_metrics: chameleon problem_management_dll
	cd source/linuxcounters/lx_diskinfo_metrics; $(MAKE)

.PHONY: lx_physnode_metrics
lx_physnode_metrics: chameleon problem_management_dll
	cd source/linuxcounters/lx_physnode_metrics; $(MAKE)

.PHONY: scripts
scripts:
	cd scripts; $(MAKE)
.PHONY: clean
clean:
	cd source/dynconsumer; $(MAKE) clean
	cd source/dynsql; $(MAKE) clean
	cd source/lighthouse2; $(MAKE) clean
	cd source/mal; $(MAKE) clean
	cd source/problem_management; $(MAKE) clean
	cd source/problem_management_dll; $(MAKE) clean
	cd source/chameleon; $(MAKE) clean
	cd source/problem_management_common; $(MAKE) clean
	cd source/problem_management_spjs; $(MAKE) clean
	cd source/publications; $(MAKE) clean
	cd source/rmsprovider; $(MAKE) clean
	cd source/sqqpidcommon; $(MAKE) clean
	cd source/timer_pop_generator; $(MAKE) clean
	cd source/universal_consumer; $(MAKE) clean
	cd source/snmppa; $(MAKE) clean
	cd source/wrapper; $(MAKE) clean
	cd source/wrapper_mon; $(MAKE) clean
	cd source/wrapper_sq; $(MAKE) clean
	cd source/consumer_wrapper; $(MAKE) clean
	cd source/una; $(MAKE) clean
	cd source/xmlgateway; $(MAKE) clean
	cd source/event_tokenizer; $(MAKE) clean
	cd source/tpaload; $(MAKE) clean
	cd source/querystatsload; $(MAKE) clean
	cd source/event_send; $(MAKE) clean
	cd source/event_templates; $(MAKE) clean
	cd source/protobuf_serialization; $(MAKE) clean
	cd source/protobuf_serialization_sq; $(MAKE) clean
	cd source/test_consumer_producer; $(MAKE) clean
	cd source/unc_configuration_generator; $(MAKE) clean
	cd source/text_protocol_adapter; $(MAKE) clean
	cd source/node_status_agent; $(MAKE) clean
	cd source/uaa; $(MAKE) clean
	cd source/se_metrics_aaa_delta; $(MAKE) clean	
	cd ../../dbsecurity/shared/dbaudit; $(MAKE) clean
	cd ../../dbsecurity/shared/dbsevents; $(MAKE) clean
	cd source/linuxcounters/loadavg_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/network_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/core_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/disk_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/memory_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/filesystem_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/virtualmem_metrics_sh;  $(MAKE) clean
	cd source/linuxcounters/lx_loadavg_metrics;  $(MAKE) clean
	cd source/linuxcounters/lx_diskinfo_metrics;  $(MAKE) clean
	cd source/linuxcounters/lx_physnode_metrics;  $(MAKE) clean
	cd scripts; $(MAKE) clean
	find . -name '*.gcda' -exec rm -f {} \;
	find . -name '*.gcno' -exec rm -f {} \;
	find . -name '*.gcov' -exec rm -f {} \;
	find . -name '*.gcda' -exec rm -f {} \;
	rm -f build.log build.log.old
	rm -rf $(SP_EXPORT_LIB)
	rm -rf $(SP_EXPORT_BIN)


#.PHONY: depend
#depend:
#	cd source/dynconsumer; $(MAKE) depend
#	cd source/dynsql; $(MAKE) depend
#	cd source/rmsprovider; $(MAKE) clean
#	cd source/universal_consumer; $(MAKE) clean
